<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 根据value值对数组进行去重:
    const arr = [{ name: '1', value: 1 }, { name: '2', value: 2 }, { name: '3', value: 1 }] -->

    <script>
	
        function Permutation(str)
        {
            // write code here
            let arr = [...str];
            console.log(arr);
            
            insert('', arr);
        }
        
        function insert(str, arr) {
            if(arr.length == 1) {
                let item = str + arr[0];
                console.log(item);
            } else {
                for(let i = 0; i < arr.length; i++) {
                    let str2 = str + arr[i];
                    let arr2 = [...arr];
                    arr2.splice(i, i + 1);
                    console.log(str2, arr);
                    insert(str2, arr2);
                }
            }
        }
		
		Permutation('a');
    </script>

</body>

</html>